Skip to content

perf: specialize whole-array sums for run-end arrays - #9823

Merged
connortsui20 merged 2 commits into
developfrom
ct/sum-runend
Sep 14, 2026
Merged

connortsui20 merged 2 commits into
developfrom
ct/sum-runend

Conversation

@connortsui20

@connortsui20 connortsui20 commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

Computes whole-array Sum and SumV2 directly from primitive run values and lengths, avoiding full decoding. Grouped sums and decimals use the existing fallback.

Changes

Reuses cached validity indices or scans the bitmap within the array's slice. Adds coverage for slice boundaries, nulls, overflow, and NaNs, plus one whole-array benchmark. Weighted floating-point sums can round differently from repeated addition, and the shared signed-overflow limitations remain unchanged. Tests and benchmarks have not been rerun for this revision.

@codspeed

codspeed Bot commented Sep 9, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.49%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 2194 untouched benchmarks
🆕 1 new benchmark
⏩ 218 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime arrow_checked_add_u32_neon[16384] 13.3 µs 20.4 µs -34.81%
WallTime filtered_owned_i64_avx2[OneNullInEight] 21.9 µs 26 µs -15.47%
Simulation allocate_drop_arrow[0] 456.9 ns 402.7 ns +13.45%
🆕 Simulation whole_array_sum_partially_valid N/A 68.7 µs N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/sum-runend (363be18) with develop (7ecae9e)

Open in CodSpeed

Footnotes

  1. 218 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@connortsui20
connortsui20 marked this pull request as ready for review September 11, 2026 17:31
Comment thread encodings/runend/benches/run_end_sum.rs Outdated
@joseph-isaacs

Copy link
Copy Markdown
Contributor

Can we not add 35 new benchmarks maybe two or 3?

Comment thread encodings/runend/src/compute/sum/whole.rs Outdated
Comment thread encodings/runend/src/compute/sum/whole.rs Outdated
Comment thread encodings/runend/src/compute/sum/grouped.rs Outdated
Comment thread encodings/runend/src/compute/sum/grouped.rs Outdated
@connortsui20
connortsui20 marked this pull request as draft September 14, 2026 14:23
Comment thread encodings/runend/src/compute/sum/grouped.rs Outdated
Comment thread encodings/runend/src/compute/sum/runs.rs Outdated
Comment thread encodings/runend/src/compute/sum/grouped.rs Outdated
@connortsui20 connortsui20 changed the title perf: specialize primitive sums for run-end arrays perf: specialize whole-array sums for run-end arrays Sep 14, 2026
@connortsui20

Copy link
Copy Markdown
Member Author

im just going to remove grouped aggregation, i dont really understand it myself and its making things complicated for me to understand

Comment on lines +4 to +7
//! SQL-style sums with explicit overflow and empty-input state.
//!
//! Encoding kernels produce scalar or grouped partials with the same state. Finalization returns
//! null for empty inputs and overflow, while [`Sum`] retains its legacy partial representation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it, I think this is useful to have (it was not obvious to me 1 week ago what the difference was, the docs on SumV2 directly are perhaps a bit too specific).

Comment thread encodings/runend/src/compute/sum/kernel.rs Outdated
Compute primitive Sum and SumV2 from run values and lengths without fully
decoding the array. Clip boundary runs to the array slice and reuse cached
validity indices or scan the bounded bitmap. Grouped sums and decimals
continue to use the existing fallback.

Cover slice boundaries, nulls, overflow, and NaNs, and add a whole-array
benchmark. Weighted floating-point sums can round differently from repeated
addition; shared signed-overflow limitations remain unchanged.

Signed-off-by: "Connor Tsui" <connor.tsui20@gmail.com>
Signed-off-by: "Connor Tsui" <connor.tsui20@gmail.com>
@robert3005

Copy link
Copy Markdown
Contributor

I think we should do a pass on the comments, there's some duplication across them

@connortsui20
connortsui20 marked this pull request as ready for review September 14, 2026 19:59
@connortsui20
connortsui20 merged commit 7286721 into develop Sep 14, 2026
86 of 88 checks passed
@connortsui20
connortsui20 deleted the ct/sum-runend branch September 14, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants